package main.components.renderers;

import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.*;

/**
 * Created by s_shmakov on 25.06.14.
 */
public class TreeSmetRenderer extends DefaultTreeCellRenderer{

    public TreeSmetRenderer() {}

    public Component getTreeCellRendererComponent(
            JTree tree,
            Object value,
            boolean sel,
            boolean expanded,
            boolean leaf,
            int row,
            boolean hasFocus) {

        super.getTreeCellRendererComponent(
                tree, value, sel,
                expanded, leaf, row,
                hasFocus);

        int idEnd = value.toString().indexOf("__") + 2;
        super.setText(value.toString().substring(idEnd, value.toString().length()));

        return this;
    }
}
